package com.yanqu.road.server.manager.activity.apprentice.handler.impl;

import com.yanqu.road.entity.activity.apprentice.ApprenticeEffectBuffProject;
import com.yanqu.road.entity.activity.apprentice.ApprenticeTalentData;
import com.yanqu.road.entity.activity.apprentice.config.ApprenticeProjectConfig;
import com.yanqu.road.entity.activity.apprentice.data.ApprenticeBuffProjectData;
import com.yanqu.road.entity.activity.apprentice.data.ApprenticeUserData;
import com.yanqu.road.server.manager.activity.apprentice.handler.ApprenticeProjectHandler;
import com.yanqu.road.server.manager.activity.apprentice.handler.param.*;

import java.util.List;
import java.util.Map;

public class ApprenticeDoProjectType3Handler implements ApprenticeProjectHandler {

    /**
     * 执行项目
     * @param req
     * @return
     */
    @Override
    public ApprenticeDoProjectResp doProject(ApprenticeDoProjectReq req) {
        return null;
    }

    /**
     * |接下来{0}次行程，|{1}职业天资{2}。
     * @param req
     */
    @Override
    public void countTalentTypeAddRate(ApprenticeCountTalentAddRateReq req) {
        ApprenticeProjectConfig projectConfig = req.getProjectConfig();
        ApprenticeBuffProjectData buffProjectData = req.getBuffProjectData();
        //buff次数减一
        buffProjectData.addNum(-1);
        String[] paramArr = projectConfig.getParam().split("\\|");
        int talentType = Integer.parseInt(paramArr[0]);
        int rate = Integer.parseInt(paramArr[1]) - 1000;
        //加成MAP
        Map<Integer, Integer> resultMap = req.getResultMap();
        int oldRate = resultMap.getOrDefault(talentType, 0);
        resultMap.put(talentType, oldRate + rate);
        //生效buff结果结果集注入
        List<ApprenticeEffectBuffProject> effectBuffProjects = req.getEffectBuffProjects();
        ApprenticeEffectBuffProject effectBuffProject = new ApprenticeEffectBuffProject(buffProjectData.getProjectId(), rate);
        effectBuffProjects.add(effectBuffProject);
    }

    @Override
    public void countSortTypeAddRate(ApprenticeCountSortAddRateReq req) {

    }
}
